home *** CD-ROM | disk | FTP | other *** search
- Subject: Memory Containers
- Sent: 12/4/96 9:30 AM
- Received: 12/4/96 9:43 AM
- From: Paul Mylchreest, paulm@teamsoft.com
- Reply-To: ODF Interest, ODF-Interest@CILabs.ORG
- To: OpenDoc Development Framework Discussion List, ODF-Interest@CILabs.
-
- Dear ODF Community:
-
- I am working on a way to store embedded parts into a database instead
- of the usual OpenDoc Bento Container.
-
- To accomplish this, I have a CMemoryContainer class that uses a
- FW_PlatformHandle as
- a container obtained by way of CreateMemoryContainer().
-
- Instances of this class also keep references to
- * the document: fContainer->AcquireDocument(ev, kODDefaultDocument);
- * the draft: fDocument->AcquireBaseDraft(ev, kODDPExclusiveWrite);
- * the storage unit: fDraft->AcquireDraftProperties(ev).
-
- Moreover, to accuratly support data interchange, I have subclassed
- FW_CEmbeddingDataInterchange
- with CMemContainerDataInterchange and have overridden ExternalizeData() and
- InternalizeData().
-
- Here is a snippet of InternalizeData()
- ==========
- FW_EInternalizeResult CMemContainerDataInterchange::InternalizeData(
- Environment* ev,
- FW_CContent* content,
- FW_CFrame* scopeFrame,
- ODStorageUnit* sourceSU,
- FW_StorageKinds storageKind,
- ODCloneKind cloneKind,
- ODPasteAsResult* embedAsInfo)
- {
- pTheContainer = FW_NEW(CMemoryContainer, (ev, sourceSU->GetSession(ev)));
-
- ODDraft
- *fromDraft = sourceSU->GetDraft(ev),
- ==> *dstDraft = pTheContainer->GetDraft(); // GET THE DRAFT FROM THE
- MEMORY CONTAINER (fDraft)
-
- // ... the rest is identical to
- FW_CEmbeddingDataInterchange::InternalizeData()
- }
- ==========
-
- So, when I embed a part, it is internalized correctly and stored into my
- database.
- This works fine!
-
- However, copying does not. Here is a snippet of ExternalizeData()
- ==========
- void CMemContainerDataInterchange::ExternalizeData(
- Environment* ev,
- FW_CContent* content,
- FW_CFrame* scopeFrame,
- ODStorageUnit* destinationSU,
- FW_StorageKinds storageKind,
- ODCloneKind cloneKind)
- {
- if ((NULL != content) && (NULL != pTheContainer))
- {
- ODDraft
- *fromDraft = pTheContainer->GetDraft(), // GET THE DRAFT FROM THE MEMORY
- CONTAINER (fDraft)
- *dstDraft = destinationSU->GetDraft(ev);
-
- FW_CCloneInfo
- cloneInfo(ev, fromDraft, scopeFrame, cloneKind);
-
- cloneInfo.BeginClone(ev, dstDraft);
-
- ==> PrivHandleExternalizeData(ev, content, destinationSU, storageKind,
- &cloneInfo);
-
- cloneInfo.EndClone(ev);
- }
- }
- ==========
-
- then this gets called
-
- ==========
- void
- FW_CEmbeddingDataInterchange::DoExternalizeSingleEmbeddedFrame(Environment*
- ev,
- ODFrame* odEmbeddedFrame,
- ODStorageUnit* destinationSU,
- FW_CCloneInfo* cloneInfo)
- {
- //.....
-
- // Clone the embedded part into the root storage unit.
- FW_CAcquiredODPart aqPart = odEmbeddedFrame->AcquirePart(ev);
- ==> ODID toRootID = cloneInfo->Clone(ev, aqPart->GetID(ev),
- destinationSU->GetID(ev), odEmbeddedFrame->GetID(ev));
-
-
- //.....
- }
- ==========
-
-
- ...and something goes terribly wrong in CMDraft.cpp:
-
- ==========
- SOM_Scope void SOMLINK CMDraftCloseCollections(CMDraft *somSelf,
- Environment *ev)
- {
- //.....
-
- ==> somSelf->Purge(ev, 0);
- PurgeAllStorageUnits(ev, _fStorageUnits, _fIDList); // purge SU, relase
- CMObjects
-
- //.....
- }
- ==========
-
- ==>ODWarning: ODRefCntObject at 34c70f0 deleted with refcount == 1
-
- here is the stack crawl:
-
- FW_CCommand::Execute()
- FW_CClipboardCommand::DoIt()
- FW_CClipboardCommand::Copy()
- FW_CClipboardCommand::PrivCopy()
- CMemContainerDataInterchange::ExternalizeData()
- FW_CEmbeddingDataInterchange::PrivHandleExternalizeData()
- FW_CEmbeddingDataInterchange::DoExternalizeSingleEmbeddedFrame()
- FW_CCloneInfo::Clone()
- CMDraftCloseCollections()
-
- Does anyone have any comments or suggestions on using Memory Containers.
- Thanks for any help.
-
- ________________
- Paul Mylchreest
- Teamsoft Inc.
- Montreal, Quebec, Canada
- http://teamsoft.com
-
-
-
-